﻿using System;

namespace housingsafety.server.Helpers
{
    /// <summary>
    /// 响应返回值
    /// </summary>
    public class RespRet
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public RespRet()
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="succ"></param>
        /// <param name="msg"></param>
        public RespRet(bool succ, string msg)
        {
            Succ = succ;
            Msg = msg;
        }

        /// <summary>
        /// 错误信息
        /// </summary>
        public string Msg { get; set; }

        /// <summary>
        /// 是否成功
        /// </summary>
        public bool Succ { get; set; }

        /// <summary>
        /// 是否debug模式
        /// </summary>
        public bool Debug
        {
            get
            {
#if DEBUG
                return true;
#else
                return false;
#endif
            }
            set
            {
                Console.WriteLine(value);
            }
        }
    }

    /// <summary>
    /// 响应返回值
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class RespRet<T> : RespRet
    {
        private T _data;

        /// <summary>
        /// 构造函数
        /// </summary>
        public RespRet()
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="succ"></param>
        /// <param name="msg"></param>
        public RespRet(bool succ, string msg)
            : base(succ, msg)
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="succ"></param>
        /// <param name="msg"></param>
        /// <param name="ret"></param>
        public RespRet(bool succ, string msg, T ret)
            : base(succ, msg)
        {
            _data = ret;
        }

        /// <summary>
        /// 返回数据体
        /// </summary>
        public virtual T Data
        {
            get => _data;
            set => _data = value;
        }
    }
}
